local M = {}

function M.test()

	--------------------------- hover事件 ---------------------------

	local rect = display.newRect(300, 300, 300, 50)

	local rectA = display.newRect(300, 280, 300, 10)
	rectA:setFillColor(0, 0, 1)
	--rectA.alpha = 0

	local rectB = display.newRect(300, 300, 300, 30)
	rectB:setFillColor(0, 1, 0)
	--rectB.alpha = 0

	local rectC = display.newRect(300, 320, 300, 10)
	rectC:setFillColor(1, 0, 0)
	--rectC.alpha = 0

	local function onHover(event)
		if (event.isPrimaryButtonDown) or (event.isSecondaryButtonDown) or (event.isMiddleButtonDown) then

			return
		end

		if not event.target.isFocous then
			--event.target.isFocous = true
			--display.getCurrentStage():setFocus(event.target)
		end
	end

	local function onPrimaryPress(event)
		print("onPrimaryPress", event.x, event.y)
		rectA.alpha = 0
		rectB.alpha = 0
		rectC.alpha = 0
		if not event.isPrimaryButtonDown then

			return
		end


		--rectA.alpha = 0
		--rectB.alpha = 0
		--rectC.alpha = 0

		if uiUtils.isInBounds(rectA, event.x, event.y) then
			rectA.alpha = 1
		elseif uiUtils.isInBounds(rectB, event.x, event.y) then
			rectB.alpha = 1
		elseif uiUtils.isInBounds(rectC, event.x, event.y) then
			rectC.alpha = 1
		end
	end


	--rect:addEventListener("mouse", onHover)
	rect:addEventListener("mouse", onPrimaryPress)



	--------------------------- touch事件 ---------------------------
	local rect1 = display.newRect(600, 600, 300, 50)
	local function onTouch(event)
		if not event.target.isFocous then
		--	event.target.isFocous = true
			--display.getCurrentStage():setFocus(event.target)
		end

		event.target.x = event.x
		event.target.y = event.y
		--print("rect1 ontouch")

	end
	rect1.alpha = 0.3
	rect1:addEventListener("touch", onTouch)

	--------------------------- test1 ---------------------------
	--local rect2 = display.newRect(900, 900, 100, 100)
	--
	--local function onHover2(event)
	--	print("rect2 onHover")
	--end
	--rect2:addEventListener("mouse", onHover2)
end

return M